from parser.kconfiglib_adapter import KconfiglibAdapter
from parser.config_model import MenuItem, ConfigItem, CommentItem, ChoiceItem

var_map={'COMPONENT_KCONFIGS_SOURCE_FILE': r'd:\Espressif\frameworks\esp-idf-v5.5.1\Kconfig'}
root=r'd:\Espressif\frameworks\esp-idf-v5.5.1\Kconfig'
adapter=KconfiglibAdapter()
items=adapter.parse_file(root, search_paths=[r'd:\Espressif\frameworks\esp-idf-v5.5.1'], var_map=var_map)
print('Using kconfiglib adapter; visited files are internal to kconfiglib')
print('Top-level items:', len(items))
print('Items:')
for it in items:
    t=type(it).__name__
    label=''
    if isinstance(it, MenuItem):
        label=it.prompt
    elif isinstance(it, ConfigItem):
        label=it.properties.prompt or it.name
    elif isinstance(it, CommentItem):
        label=it.text
    elif isinstance(it, ChoiceItem):
        label=it.prompt or 'choice'
    print(f" - {t}: {label}")
